class CreatePosts < ActiveRecord::Migration
  def self.up
    create_table :posts do |t|
      t.string     :title, :null=>false
      t.string     :slug, :limit=>50
      t.text       :brief
      t.text       :content, :null=>false, :limit=>2.megabytes
      t.string     :cached_tag_list
      t.boolean    :is_visible, :default=>1
      t.integer    :language, :limit=>1, :default=>0
      
      t.integer    :user_id
      t.integer    :structure_id
      t.integer    :comments_count, :default=>0
      
      t.timestamps
    end
    
    add_index :posts, :user_id, :name=>"fk_user"
    add_index :posts, :structure_id, :name=>"fk_structure"
    add_index :posts, :is_visible, :name=>"idx_posts"
    
    Post.create_translation_table! :title => :string, :content=>:text, :brief=>:text
  end

  def self.down
    drop_table :posts
    Post.drop_translation_table!
  end
end
